package com.cheng.im.service.redis.seq;

import com.cheng.im.common.constants.RedisConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * 用户序列号写入用户的缓存，各种序列号使用hash类型保存
 */
@Service
public class WriteUserSeq {

    //redis
    //uid friend 10
    //    group 12
    //    conversation 123
    @Autowired
    RedisTemplate redisTemplate;

    /**
     * appid:seq:userid (Hash类型)
     *      friendshipRequestSeq: 99
     * @param appId
     * @param userId
     * @param type
     * @param seq
     */
    public void writeUserSeq(String appId, String userId, String type, Long seq){
        String key = appId + ":" + RedisConstants.SeqPrefix + ":" + userId;
        redisTemplate.opsForHash().put(key, type, seq);
    }

}

